<template>
  <el-dialog
      v-model="dialog.visible"
      append-to-body
      :before-close="close"
      title="编辑模型信息">
    <avue-form v-if="modelOption" :option="modelOption" ref="processModelForm" v-model="formModel"
               @submit="saveModel"></avue-form>
  </el-dialog>
</template>
<script>
import actModelOption from "@/option/start/activiti/actModelOption";

export default {
  name: "editModelDialog",
  data() {
    return {
      dialog: {
        visible: false,
      },
      formModel: {},
      modelOption: null,
    }
  },
  methods: {
    show(model) {
      this.formModel = model;
      let modelOption = actModelOption();
      if (!model.id) {
        modelOption.boxType = "add";
        this.processModel = {}
      } else {
        modelOption.boxType = "edit";
      }
      this.modelOption = modelOption;
      this.dialog.visible = true;
    },
    saveModel(formModel, done) {
      const close = () => {
        done();
        this.close()
      }
      this.$emit("submit", formModel, close);
    },
    close() {
      this.dialog.visible = false;
      this.modelOption = null;
      this.formModel = {};
    }
  }
}
</script>

<style scoped>

</style>